// 导入二次封装的axios
import request from '@/utils/request'
//导入类型
import type {TrademarkResponseData,Trademark} from './type/trademark'

enum API {
  //获取品牌列表的地址
  TRADEMARK_URL = '/admin/product/baseTrademark',
  //新增品牌
  ADD_TRADEMARK_URL = '/admin/product/baseTrademark/save',
  //修改品牌
  UPDATE_TRADEMARK_URL = '/admin/product/baseTrademark/update'
}

//获取品牌列表
export const reqTrademarkList = (page:number,limit:number) => request.get<any,TrademarkResponseData>(API.TRADEMARK_URL + `/${page}/${limit}`)

//修改或新增品牌
export const reqUpdateOrAddTrademark = (data:Trademark) => {
  if (data.id) {
    return request.put<any,any>(API.UPDATE_TRADEMARK_URL,data)
  } else {
    return request.post<any,any>(API.ADD_TRADEMARK_URL,data)
  }
}